<script setup lang="ts">
import { useUserInfoStore } from '@/store/userInfo'

const router = useRouter()
const userInfoStore = useUserInfoStore()

function handleViewProtocol(type: '用户协议' | '隐私政策') {
  router.push({
    name: 'protocol',
    params: { type },
  })
}

function handleLogout() {
  userInfoStore.setUserInfo()
  router.replaceAll('index')
}
</script>

<template>
  <Spacer height="30" />
  <view class="mx-24rpx rounded-20rpx bg-white">
    <ListCell label="用户协议" @tap="handleViewProtocol('用户协议')">
      <image
        class="h-25rpx w-13rpx"
        src="@/static/images/cheveron-right.png"
      />
    </ListCell>
    <Divider width="642" color="#E6E6E6" />
    <ListCell label="隐私政策" @tap="handleViewProtocol('隐私政策')">
      <image
        class="h-25rpx w-13rpx"
        src="@/static/images/cheveron-right.png"
      />
    </ListCell>
  </view>

  <view class="fixed bottom-30rpx x-center" @tap="handleLogout">
    <RGButton>退出登录</RGButton>
  </view>
</template>

<route lang="yaml">
name: 'settings'
style:
  navigationBarTitleText: '设置'
</route>
